package com.cu.jiekong.controller;

import com.cu.jiekong.constants.ResultStatus;
import com.cu.jiekong.frame.model.Ret;
import com.cu.jiekong.model.BorrowInfo;
import com.cu.jiekong.service.BorrowInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author jintian
 * @date 14:30
 */
@Controller
@RequestMapping("borrow")
public class BorrowController {

    @Autowired
    private BorrowInfoService borrowInfoService;

    /**
     * 申请借款
     *
     * @param borrowInfo
     * @return
     */
    @ResponseBody
    @RequestMapping("applyBorrow")
    public Ret applyBorrow(BorrowInfo borrowInfo, String sessionId) {
        try {
            return borrowInfoService.applyBorrow(borrowInfo, sessionId);
        } catch (Exception e) {
            return new Ret(ResultStatus.RESULT_999999.getCode(), ResultStatus.RESULT_999999.getMsg());
        }
    }

}
